package com.yztc.xiami_app.utils;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;

/**
 * Created by 周旭 on 2016/11/16.
 * OkHttp工具类
 */

public class OkhttpUtils {


    //Get请求获取网络数据
    public static void doGet(String url,Callback callback){
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder().url(url).build();
        Call call = client.newCall(request);
        call.enqueue(callback);
    }

    //获取Json字符串
    public static String getStr(Response response) throws IOException {
        ResponseBody body = response.body();
        return body.string();
    }

}
